package com.stu.stusystem.controller.chat;

import com.stu.stusystem.common.ApiResult;
import com.stu.stusystem.model.chat.ChatFriends;
import com.stu.stusystem.service.chat.ChatFriendsService;
import com.stu.stusystem.service.system.vo.StuUserVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author: cxt
 * @time: 2021/6/15
 */
@RestController
@RequestMapping("/chat/friends")
public class ChatFriendsController {

    private ChatFriendsService chatMsgService;

    @ApiOperation("好友列表")
    @GetMapping("/get")
    public List<StuUserVO> getFriends(@RequestParam("id") String id) {
        return this.chatMsgService.getFriends(id);
    }

    @ApiOperation("获取待添加列表")
    @GetMapping("/stay")
    public List<StuUserVO> getStay(@RequestParam("id") String id) {
        return this.chatMsgService.getStay(id);
    }

    @ApiOperation("添加")
    @PostMapping("/add")
    public ApiResult<String> add(@Valid @RequestBody ChatFriends chatFriends) {
        this.chatMsgService.add(chatFriends);
        return ApiResult.success();
    }

    @ApiOperation("删除好友")
    @GetMapping("/remove")
    public ApiResult<String> removeFriend(@RequestParam("id") String id, @RequestParam("fId") String fId) {
        this.chatMsgService.removeFriend(id, fId);
        return ApiResult.success();
    }

    @Autowired
    public void setChatMsgService(ChatFriendsService chatMsgService) {
        this.chatMsgService = chatMsgService;
    }
}
